package com.shadow.ui.director
{
	import com.shadow.ui.container.town.base.TownContainer;
	import com.shadow.ui.events.MapEvent;
	import com.shadow.ui.events.event_container.MapEventContainer;
	import com.shadow.ui.map.stage.base.MapStage;
	
	import flash.display.Sprite;
	import flash.display.Stage;

	/**
	 * 显示对象处理器
	 * @author Liseen
	 * 
	 */	
	public class DisplayDirector
	{
		private static var _instance:DisplayDirector;
		
		public var stage:Sprite;
		public var currentTownContainer:TownContainer;
		public var currentMapStage:MapStage;
		public function DisplayDirector(value:Singleton)
		{
			
		}
		/**
		 *获取显示对象导演对象 
		 * @return 
		 * 
		 */		
		public static function getInstance():DisplayDirector
		{
			if(DisplayDirector._instance==null){
				DisplayDirector._instance = new DisplayDirector(new Singleton());
			}
			
			return DisplayDirector._instance;
		}
		
		/**
		 *添加新显示对象到列表中 
		 * @param newView
		 * @param parent
		 * 
		 */		
		public function addView(newView:Sprite,parent:Sprite=null):void
		{
			if(parent==null){
				parent = this.stage;
			}
			
			if (newView != null)
			{
				parent.addChild(newView);
				MapEventContainer.getInstance().dispatchEvent(new MapEvent(MapEvent.ADDED_TOWN_CONTAINER));
			}
			if (newView is TownContainer)
			{
				currentTownContainer = (newView as TownContainer);
			}
		}
		
	}
}

class Singleton 
{
	
	
}